@extends("admin.layout.common")
@section('content')
    <link rel="stylesheet" href="{{asset('css/finance/FinanceRecheck.css')}}">
    <div class="content">
        <h1 class="h1">财务分账中心</h1>
        <!-- 公共结束 -->
        <div class="transmit">
            <p class="p1">
                <label for="">分账类型：</label>
                <select name="account-type" id="account-type">
                    <option @if($type == 0) selected @endif value="0">选择分账类型</option>
                    <option @if($type == 1) selected @endif value="1">音乐人/代理分账</option>
                    <option @if($type == 2) selected @endif value="2">指定分账</option>
                </select>
            </p>
            <table border="1">
                <tr>
                    <th>分账ID</th>
                    <th>分账周期</th>
                    <th>分账类型</th>
                    <th>分账金额</th>
                    <th>内部支出</th>
                    <th>结果</th>
                </tr>
                @foreach($accounts as $account)
                    @if(($type == 0 || $type == 1) && $account->music_status != 0)
                        <tr>
                            <td>{{$account->id}}</td>
                            <td>{{$account->time}}</td>
                            <td>音乐人</td>
                            <td>{{$account->music_total}}</td>
                            <td>{{$account->cost_total}}</td>
                            <td>{{$account->music_status_text}}</td>
                        </tr>
                        <tr>
                            <td>{{$account->id}}</td>
                            <td>{{$account->time}}</td>
                            <td>代理</td>
                            <td>{{$account->agent_total}}</td>
                            <td>{{$account->cost_total}}</td>
                            <td>{{$account->agent_status_text}}</td>
                        </tr>
                    @endif
                    @if(($type == 0 || $type == 2) && $account->appoint_status != 0)
                        <tr>
                            <td>{{$account->id}}</td>
                            <td>{{$account->time}}</td>
                            <td>指定</td>
                            <td>{{$account->appoint_total}}</td>
                            <td>{{$account->cost_total}}</td>
                            <td>{{$account->appoint_status_text}}</td>
                        </tr>
                    @endif
                @endforeach
            </table>
            {{$accounts->links()}}
            <div id="demo3" style="text-align: center;margin-top:30px;font-size:28px;"></div>
        </div>
    </div>
    {{--<script src="{{URL::asset('js/finance/sub-FinanceRecheck.js')}}"></script>--}}
    <script>
        $("#account-type").change(function () {
            const typeValue = $("#account-type").val();
            if (typeValue) {
                window.location.href = 'http://' + HTTP_HOST + '/admin/ledgerRecord/' + typeValue;
            }
        });
    </script>
@endsection